package com.homedo.odin.solution.enumcode.require;

import org.apache.commons.lang.ArrayUtils;

/**
 * 用户需求状态
 *
 * @author yanghaohao
 */
public enum UserRequireStatusEnum {

    NOT_REPLY(0, "未回复"), REPLY(1, "已回复");

    private int key;
    private String value;

    UserRequireStatusEnum(int key, String value) {
        this.value = value;
        this.key = key;
    }

    // 普通方法
    public static String getName(int key) {
        for (UserRequireStatusEnum b : UserRequireStatusEnum.values()) {
            if (b.getKey() == key) {
                return b.value;
            }
        }
        return null;
    }

    public static Integer getKey(String name) {
        int key = 0;
        for (UserRequireStatusEnum p : UserRequireStatusEnum.values()) {
            key = p.getKey();
            if (getName(key).equals(name)) {
                return key;
            }
        }
        return 0;
    }

    public String getValue() {
        return value;
    }

    public int getKey() {
        return key;
    }

    public static boolean validateType(int type) {
        return ArrayUtils.contains(new int[]{NOT_REPLY.getKey(), REPLY.getKey()}, type);
    }

}
